<template>
    <div id="docOrderDetails">
        <header>
            <i @click="goBack()"></i>
            <div>加单详情</div>
        </header>
        <div class="box">
            <ul class="orderDetails">
                <li>
                    <span>
                        商品明细
                    </span>
                </li>
                <li v-for='(item,index) in gids' :key='index' v-if="gids.length>0">
                    <img :src="item.img_url" width='45' height="45" alt="">
                    <h3>{{item.name}}</h3>
                    <div>
                        <i>x{{item.num}}</i>
                        <span>￥{{item.price}}</span>
                    </div>
                </li>
            </ul>
            <ul class="order">
                <li>
                    <span>订单时间:</span>
                    <div>{{orderObj.time}}</div>
                </li>
                <li>
                    <span>单号:</span>
                    <div class='ellipsis' style='flex: 1'>{{orderObj.order_num?orderObj.order_num.split('*')[1]:''}}</div>
                </li>
            </ul>
        </div>
    </div>
</template>
<script>
    import { MessageBox } from 'mint-ui';
    export default {
        data() {
            return {
                id: '',  //订单id
                orderObj: {},
                gids: [],
                docinfo: {},  //医生下单信息
                type: '',
                timeOutEvent: 0,
                user: '', //判断入口 医生or诊室
            }
        },
        filters: {
            // 把数字转换成字符串
            toStr(arr) {
                if(arr) {
                    const str = arr.join();
                    return str;
                }
            },
            // 获取数组长度
            getLen(arr) {   
                if(arr) {
                    const len = arr.length;
                    return len;
                }
            },
        },
        methods: {
            //返回上一级
            goBack() {
                this.$router.back();
            },  
            //判断入口 医生还是诊室
            judgmentUser() {
                this.user = this.$route.query.user;
                this.id = this.$route.query.id;
                this.type = this.$route.query.type;
            },
            // 根据id获取订单详情
            getObj() {
                this.$api.get(this.$api.baseURLSchool,"select_cid/doctor_order_add/"+this.id,{},r => {
                    if(r.data.ret == 1) {
                        this.orderObj = r.data.info;
                        this.gids = JSON.parse(this.orderObj.gids);
                    }	
                },err => {
                    console.log(err);
                })
            },
            // 计时说明
            goTip() {
                this.$router.push({name: 'timingInstructions'});
            }, 
            // 提示商品类表可编辑
            goTip2() {
                this.$utils._toast("长按可编辑商品列表");
            }, 
           
            //查看费用明细
            lookChargeDetails() {
                this.$router.push({name: 'chargeDetails'});
            },
        
        },
        created() {
            this.judgmentUser();
            this.getObj();
           
        }
    }    
</script>
<style lang="scss" scoped>
    
</style>

 
